﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebDocDB.DocumentDBManager;

namespace WebDocDB.Managers
{
    public class AccountManager : IAccountManager
    {
        public AccountSettings GetAccountSettings()
        {
            var accountSettings = HttpContext.Current.Session["AccountSettings"];            
            return accountSettings != null ? (AccountSettings) accountSettings : null;
        }

        public void SaveAccountSettings(string accountUrl, string accountKey)
        {
            var accountSettings = new WebDocDB.DocumentDBManager.AccountSettings();
            accountSettings.EndpointUrl = accountUrl;
            accountSettings.MasterKey = accountKey;
            accountSettings.ConnectionMode = Microsoft.Azure.Documents.Client.ConnectionMode.Direct;
            accountSettings.Protocol = Microsoft.Azure.Documents.Client.Protocol.Tcp;

            HttpContext.Current.Session["AccountSettings"] = accountSettings;
        }
    }
}